package com.study;

import com.study.util.FileUtil;

import java.util.List;

/**
 * TODO
 *
 * @author wanghuilong
 * @version 1.0
 * @date 2021/11/26 10:31 上午
 */
public class Test6 {


    public static void main(String[] args) {

        String sql1 = "update sku s,(select ss.standard_sku_code,ss.spu_code,s.spu_name from standard_sku ss INNER JOIN spu s on ss.spu_code = s.spu_code where standard_business_code = '${value1}') d set " +
                "s.standard_sku_code = d.standard_sku_code,s.spu_code = d.spu_code,s.spu_name=d.spu_name where s.external_code = '${value2}';";


        String sql2 = "update item i,(select ss.standard_sku_code,ss.spu_code,s.spu_name from standard_sku ss INNER JOIN spu s on ss.spu_code = s.spu_code where standard_business_code = '${value1}') d set " +
                "i.standard_sku_code = d.standard_sku_code,i.spu_code = d.spu_code where i.merchant_sku_code in (select sku_code from sku where external_code = '${value2}');";

        String sql3 = "select ss.standard_sku_code,ss.spu_code,s.spu_name,(select sku_code from sku where external_code = '${value2}'),(select item_code from item where merchant_sku_code = (select sku_code from sku where external_code = '${value2}')) from standard_sku ss INNER JOIN spu s on ss.spu_code = s.spu_code where standard_business_code = '${value1}' UNION";

        List<String> strings = FileUtil.readTxtFileIntoStringArrList("/Users/wanghuilong/IdeaProjects/lazy/src/main/resources/file/4.txt", null);
        for (String str : strings) {
            String[] split = str.trim().split("\t\t\t");
//            System.out.println(split[0]+","+split[1]);
//            System.out.println(sql1.replace("${value1}",split[1]).replace("${value2}",split[0]));
//            System.out.println(sql2.replace("${value1}",split[1]).replace("${value2}",split[0]));
            System.out.println(sql3.replace("${value1}", split[1]).replace("${value2}", split[0]));
        }


    }

}
